package com.cy.java.net;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class MainClient {
    public static void main(String[] args) throws IOException {//客户端 (类似浏览器)
        //浏览器,向指定服务建立连接
        Socket socket = new Socket("localhost", 9999);
        //向服务端写一句话
        ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
        out.writeUTF("你好,服务器!");
        out.flush();
        out.close();
    }
}
